<template>
  <div style="width: 20%;margin-top: 20%;margin-left: 40%;border: solid">
    <div style="margin-top: 30px;margin-right: 30px">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="账号">
          <el-input v-model="form.uname" ></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="form.upass" ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">登录</el-button>
          <el-button type="primary" @click="toRegister">注册</el-button>
        </el-form-item>
      </el-form>

      <el-menu router style="border:none" :default-active="$route.path">
        <el-menu-item index="/main">
          <template slot="title">
            <i class="el-icon-house"></i>
            <span>系统首页</span>
          </template>
        </el-menu-item>
        <el-menu-item index="/element">
          Element页面
        </el-menu-item>
        <el-menu-item>
          <template slot="title">
            <i class="el-icon-house"></i>
            <span>系统首页</span>
          </template>
        </el-menu-item>
        <el-menu-item>
          <template slot="title">
            <i class="el-icon-house"></i>
            <span>系统首页</span>
          </template>
        </el-menu-item>
        <el-submenu>
          <template slot="title">
            <i class="el-icon-menu"></i>
            <span>信息管理</span>
          </template>
          <el-menu-item>用户信息</el-menu-item>
        </el-submenu>
      </el-menu>
    </div>

  </div>


</template>
<script>
import axios from "axios";

export default {
  data() {
    return {
      form: {
        uname:'',
        upass:''
      }
    }
  },
  methods: {
    onSubmit() {
      axios.post('http://localhost:8090/common/login', {
        name:this.form.uname,
        pass:this.form.upass
      }).then(function (response) {
        alert(response.data);
        console.log(response.data);
      })
    },
    toRegister(){
      this.$router.push("/login")
    }
  }
}
</script>

